class AddActivityLoggingToUsers < ActiveRecord::Migration::Current
  def self.up
    add_column :users, :last_login_at,     :datetime, default: nil
    add_column :users, :last_logout_at,    :datetime, default: nil
    add_column :users, :last_activity_at,  :datetime, default: nil
    add_column :users, :last_login_from_ip_address, :string, default: nil

    add_index :users, %i[last_logout_at last_activity_at]
  end

  def self.down
    remove_index :users, %i[last_logout_at last_activity_at]

    remove_column :users, :last_activity_at
    remove_column :users, :last_logout_at
    remove_column :users, :last_login_at
    remove_column :users, :last_login_from_ip_address
  end
end
